using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableEquipOutfitDao:DaoBase<TableEquipOutfit>
    {
        public override void AddPrimaryIndex(TableEquipOutfit model)
        {
            cachePrimary[model.id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableEquipOutfit.txt";
        }

        protected override TableEquipOutfit ParseRowData(string[] rowData)
        {
            TableEquipOutfit data = new TableEquipOutfit();

            if (string.IsNullOrEmpty(rowData[0]))
            {
                data.id = 0;
            }
            else
            {
                data.id = int.Parse(rowData[0]);
            }
			data.outfitId = rowData [1];

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.num = 0;
            }
            else
            {
                data.num = int.Parse(rowData[2]);
            }

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.hp = 0;
            }
            else
            {
                data.hp = double.Parse(rowData[3]);
            }

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.att = 0;
            }
            else
            {
                data.att = double.Parse(rowData[4]);
            }

            if (string.IsNullOrEmpty(rowData[5]))
            {
                data.pdef = 0;
            }
            else
            {
                data.pdef = double.Parse(rowData[5]);
            }

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.mdef = 0;
            }
            else
            {
                data.mdef = double.Parse(rowData[6]);
            }

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.cri = 0;
            }
            else
            {
                data.cri = double.Parse(rowData[7]);
            }

            if (string.IsNullOrEmpty(rowData[8]))
            {
                data.perhit = 0;
            }
            else
            {
                data.perhit = double.Parse(rowData[8]);
            }

            if (string.IsNullOrEmpty(rowData[9]))
            {
                data.anticri = 0;
            }
            else
            {
                data.anticri = double.Parse(rowData[9]);
            }

            if (string.IsNullOrEmpty(rowData[10]))
            {
                data.perevade = 0;
            }
            else
            {
                data.perevade = double.Parse(rowData[10]);
            }

            if (string.IsNullOrEmpty(rowData[11]))
            {
                data.damadd = 0;
            }
            else
            {
                data.damadd = double.Parse(rowData[11]);
            }

            if (string.IsNullOrEmpty(rowData[12]))
            {
                data.damsub = 0;
            }
            else
            {
                data.damsub = double.Parse(rowData[12]);
            }

            return data;
        }


        public override void AddOneIndex(TableEquipOutfit model)
        {
            if (!cacheOneIndex.ContainsKey(model.outfitId.ToString()))
            {
                cacheOneIndex[model.outfitId.ToString()] = new List<TableEquipOutfit>();
            }
            cacheOneIndex[model.outfitId.ToString()].Add(model);
        }
    

    }

}
